const logout = document.querySelector('.logout');
axios.get("student/list").then(r => {
    toastr.success("页面登录成功");
})

//给退出绑定点击事件
logout.addEventListener('click', function (e) {
    const out = confirm("您确定要退出吗");
    if (out) {
        //删除本地存储
        localStorage.removeItem("token");
        //弹框
        toastr.info("您已成功退出");
        setTimeout(function () {
            location.href = './login.html'
        }, 1500)
    }
})

// 左侧菜单的一级列表功能
const navList = document.querySelectorAll('.nav>li>a');

navList.forEach(v => {
    v.addEventListener("click", function () {
        // 绑定第二个span 切换类名
        v.querySelector(".toggle").classList.toggle("toggleone");
        // 给a的兄弟元素ul 切换show类名
        v.nextElementSibling.classList.toggle("show")
    })
})

// 给左侧二级菜单绑定点击事件
const navListtwo = document.querySelectorAll('.nav ul a ');

navListtwo.forEach(v => {
    v.addEventListener('click', function (e) {
        document.querySelector("a.active").classList.remove("active");
        this.classList.add("active");
    })
})

// 初始化
const init = document.querySelector('.init');
init.addEventListener('click', function (e) {
    axios.get("/init/data").then(r => console.log(r))
})